Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better error message and error handling for data plane gateway #916

Merged
merged 14 commits into from
Jan 8, 2024

Conversation

travjenkins
Copy link
Member

@travjenkins travjenkins commented Jan 5, 2024

Issues

#915

Changes

915

  • Got journalData hook using proper error handling
  • Mare the error message component a bit more safe by including a fallback message
  • More logging to find possible issues

Misc

  • Created shared utils for data plane gateway to share
  • Added FormatJS linting rules

Tests

Manually tested

  • Messed with the URL blocking via Chrome debugger to view shards/journals

Automated tests

  • N/A

Screenshots

  • N/A

@travjenkins travjenkins marked this pull request as ready for review January 5, 2024 20:20
@travjenkins travjenkins requested a review from a team as a code owner January 5, 2024 20:20
Comment on lines +42 to +43
'formatjs/enforce-placeholders': 'error',
// 'formatjs/no-literal-string-in-jsx': 'error',
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keeping this off for right now. Will make a stand alone PR to fix all of these while turning it on.

Comment on lines +41 to +56
const dataPlaneListResponse = await dataPlaneFetcher_list(
journalClient,
journalSelector,
'JournalData'
);

if (!Array.isArray(dataPlaneListResponse)) {
return Promise.reject(dataPlaneListResponse);
}

return {
journals:
dataPlaneListResponse.length > 0
? dataPlaneListResponse
: [],
};
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Made these use identical variable names to make merging these together later easier.

I was going to just have the array and response in the list call but ran into typescript issues and did not want to keep trying to wrangle those.

Comment on lines +38 to +43
// There is a small chance this can happen so adding custom event to track it
// Happened before when journal data hook wasn't catching errors
const id = error.message ?? FALLBACK;
if (id === FALLBACK) {
logRocketEvent(CustomEvents.ERROR_MISSING_MESSAGE);
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make this super safe. This spot should no longer get hit - but in case making sure we have an event just for it.

We could figure this out with the event/logging above but I want to be able to search for this and not have to manually review sessions.

Comment on lines +45 to +66
// This can throw an error! Used within fetchers within SWR that is fine and SWR will handle it
// TODO (typing)
// I hate this but I need to get the bug finished
const result = await client.list(selector as any);

// Check for an error
if (result.err()) {
// Unwrap the error, log the error, and reject the response
const error = result.unwrap_err();
logRocketConsole(`${key} : error : `, error);
return Promise.reject(error.body);
}

try {
// No error so should be fine to unwrap
const unwrappedResponse = result.unwrap();
return await Promise.resolve(unwrappedResponse);
} catch (error: unknown) {
// This is just here to be safe. We'll keep an eye on it and possibly remove
logRocketConsole(`${key} : unwrapError : `, error);
return Promise.reject(error);
}
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just snagged this from the shards hook.

Copy link
Member

@kiahna-tucker kiahna-tucker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As aforementioned, the error alert is still pretty aggressive. Does this alert still need a full title, subtitle, and description or can the compact, AlertBox styling be used here?

Reference

Data Preview section error

journal-error-handling

@@ -183,6 +183,8 @@ const Error: ResolvedIntlConfig['messages'] = {
'error.hintLabel': `Hint:`,
'error.descriptionLabel': `Description:`,
'error.tryAgain': `Try again and if the issue persists please contact support.`,

'error.fallBack': `no error details to display`,
Copy link
Member

@kiahna-tucker kiahna-tucker Jan 8, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we comfortable with this terse and vague of a fallback message? If so, I would recommend using sentence case here and appending with a period.

Out of curiosity, why does a generic error message -- along the lines of 'error.tryAgain' and 'errorBoundry.chunkNotFetched.error.message1' -- not work in this case?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. The point is to keep it super vague so it is not relied on too much as it is simply a failsafe.

Copy link
Member

@kiahna-tucker kiahna-tucker left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Approved with manual testing since it seems to function and appear as intended at this point in time.

@travjenkins travjenkins merged commit d1f5232 into main Jan 8, 2024
3 checks passed
@travjenkins travjenkins deleted the travjenkins/bug/formatJsCrash branch January 8, 2024 16:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants